package com.ruoyi.life.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.life.domain.FeApartmentLeaseDetail;
import com.ruoyi.life.service.IFeApartmentLeaseDetailService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 公寓房源租赁明细Controller
 *
 * @author cjie
 * @date 2022-09-13
 */
@Api(tags = " 公寓房源租赁明细")
@RestController
@RequestMapping("/feApartmentLeaseDetail")
public class FeApartmentLeaseDetailController extends BaseController {
    @Autowired
    private IFeApartmentLeaseDetailService feApartmentLeaseDetailService;

    /**
     * 查询公寓房源租赁明细列表
     */
    @ApiOperation(value="查询公寓房源租赁明细列表", notes="查询公寓房源租赁明细列表")
    @PreAuthorize(hasPermi = "life:feApartmentLeaseDetail:list")
    @GetMapping("/list")
    public TableDataInfo list(FeApartmentLeaseDetail feApartmentLeaseDetail) {
        startPage();
        List<FeApartmentLeaseDetail> list = feApartmentLeaseDetailService.selectFeApartmentLeaseDetailList(feApartmentLeaseDetail);
        return getDataTable(list);
    }

    /**
     * 导出公寓房源租赁明细列表
     */
    @ApiOperation(value="导出公寓房源租赁明细列表", notes="导出公寓房源租赁明细列表")
    @PreAuthorize(hasPermi = "life:feApartmentLeaseDetail:export")
    @Log(title = "公寓房源租赁明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FeApartmentLeaseDetail feApartmentLeaseDetail) throws IOException {
        List<FeApartmentLeaseDetail> list = feApartmentLeaseDetailService.selectFeApartmentLeaseDetailList(feApartmentLeaseDetail);
        ExcelUtil<FeApartmentLeaseDetail> util = new ExcelUtil<FeApartmentLeaseDetail>(FeApartmentLeaseDetail.class);
        util.exportExcel(response, list, "公寓房源租赁明细数据");
    }
    /**
     * 获取公寓房源租赁明细详细信息
     */
    @ApiOperation(value="获取公寓房源租赁明细详细信息", notes="获取公寓房源租赁明细详细信息")
    @PreAuthorize(hasPermi = "life:feApartmentLeaseDetail:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return AjaxResult.success(feApartmentLeaseDetailService.selectFeApartmentLeaseDetailById(id));
    }

    /**
     * 新增公寓房源租赁明细
     */
    @ApiOperation(value="新增公寓房源租赁明细", notes="新增公寓房源租赁明细")
    @PreAuthorize(hasPermi = "life:feApartmentLeaseDetail:add")
    @Log(title = "公寓房源租赁明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FeApartmentLeaseDetail feApartmentLeaseDetail) {
        return toAjax(feApartmentLeaseDetailService.insertFeApartmentLeaseDetail(feApartmentLeaseDetail));
    }

    /**
     * 修改公寓房源租赁明细
     */
    @ApiOperation(value="修改公寓房源租赁明细", notes="修改公寓房源租赁明细")
    @PreAuthorize(hasPermi = "life:feApartmentLeaseDetail:edit")
    @Log(title = "公寓房源租赁明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FeApartmentLeaseDetail feApartmentLeaseDetail) {
        return toAjax(feApartmentLeaseDetailService.updateFeApartmentLeaseDetail(feApartmentLeaseDetail));
    }

    /**
     * 删除公寓房源租赁明细
     */
    @ApiOperation(value="删除公寓房源租赁明细", notes="删除公寓房源租赁明细")
    @ApiImplicitParam(name = "ids", value = "公寓房源租赁明细ID数组", required = true,paramType = "path", allowMultiple=true, dataType = "String")
    @PreAuthorize(hasPermi = "life:feApartmentLeaseDetail:remove")
    @Log(title = "公寓房源租赁明细", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(feApartmentLeaseDetailService.deleteFeApartmentLeaseDetailByIds(ids));
    }
}
